home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qvector.h.z / qvector.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  5.2 KB  |  138 lines

  1. /****************************************************************************
  2. ** $Id: qvector.h,v 2.3 1998/07/03 00:09:47 hanord Exp $
  3. **
  4. ** Definition of QVector template/macro class
  5. **
  6. ** Created : 930907
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QVECTOR_H
  25. #define QVECTOR_H
  26.  
  27. #ifndef QT_H
  28. #include "qgvector.h"
  29. #endif // QT_H
  30.  
  31.  
  32. #if defined(USE_MACROCLASS)
  33.  
  34. #include "qgeneric.h"
  35.  
  36. #if !defined(name2)
  37. #define name2(a,b)    name2_xx(a,b)
  38. #define name2_xx(a,b) a##b
  39. #endif
  40.  
  41. #if defined(DEFAULT_MACROCLASS)
  42. #define QVectordeclare QVectorMdeclare
  43. #define QVector QVectorM
  44. #endif
  45. #define QVectorM(type) name2(QVectorM_,type)
  46.  
  47. #define QVectorMdeclare(type)                              \
  48. class QVectorM(type) : public QGVector                          \
  49. {                                          \
  50. public:                                          \
  51.     QVectorM(type)()            {}                      \
  52.     QVectorM(type)( uint size ) : QGVector(size) {}                  \
  53.     QVectorM(type)( const QVectorM(type) &v ) : QGVector(v) {}              \
  54.    ~QVectorM(type)()            { clear(); }                  \
  55.     QVectorM(type)& operator=(const QVectorM(type) &v)                  \
  56.             { return (QVectorM(type)&)QGVector::operator=(v); }   \
  57.     type **data()   const        { return (type **)QGVector::data(); } \
  58.     uint  size()    const        { return QGVector::size(); }          \
  59.     uint  count()   const        { return QGVector::count(); }          \
  60.     bool  isEmpty() const        { return QGVector::count() == 0; }    \
  61.     bool  isNull()  const        { return QGVector::size() == 0; }     \
  62.     bool  resize( uint size )        { return QGVector::resize(size); }    \
  63.     bool  insert( uint i, const type *d){ return QGVector::insert(i,(GCI)d); }\
  64.     bool  remove( uint i )        { return QGVector::remove(i); }          \
  65.     type *take( uint i )        { return (type *)QGVector::take(i); } \
  66.     void  clear()            { QGVector::clear(); }              \
  67.     bool  fill( const type *d, int size=-1 )                      \
  68.                     { return QGVector::fill((GCI)d,size);}\
  69.     void  sort()            { QGVector::sort(); }              \
  70.     int      bsearch( const type *d ) const{ return QGVector::bsearch((GCI)d); } \
  71.     int      findRef( const type *d, uint i=0 ) const                  \
  72.                     { return QGVector::findRef((GCI)d,i);}\
  73.     int      find( const type *d, uint i= 0 ) const                  \
  74.                     { return QGVector::find((GCI)d,i); }  \
  75.     uint  containsRef( const type *d ) const                      \
  76.                 { return QGVector::containsRef((GCI)d); }     \
  77.     uint  contains( const type *d ) const                      \
  78.                     { return QGVector::contains((GCI)d); }\
  79.     type *operator[]( int i ) const    { return (type *)QGVector::at(i); }   \
  80.     type *at( uint i ) const        { return (type *)QGVector::at(i); }   \
  81.     void  toList( QGList *list ) const    { QGVector::toList(list); }          \
  82. private:                                      \
  83.     void  deleteItem( GCI d ) { if ( del_item ) delete (type *)d; }          \
  84. }
  85.  
  86. #endif // USE_MACROCLASS
  87.  
  88.  
  89. #if defined(USE_TEMPLATECLASS)
  90.  
  91. #if defined(DEFAULT_TEMPLATECLASS)
  92. #undef    QVector
  93. #define QVector QVectorT
  94. #endif
  95.  
  96. template<class type> class QVectorT : public QGVector
  97. {
  98. public:
  99.     QVectorT()                {}
  100.     QVectorT( uint size ) : QGVector(size) {}
  101.     QVectorT( const QVectorT<type> &v ) : QGVector(v) {}
  102.    ~QVectorT()                { clear(); }
  103.     QVectorT<type> &operator=(const QVectorT<type> &v)
  104.             { return (QVectorT<type>&)QGVector::operator=(v); }
  105.     type **data()   const        { return (type **)QGVector::data(); }
  106.     uint  size()    const        { return QGVector::size(); }
  107.     uint  count()   const        { return QGVector::count(); }
  108.     bool  isEmpty() const        { return QGVector::count() == 0; }
  109.     bool  isNull()  const        { return QGVector::size() == 0; }     \
  110.     bool  resize( uint size )        { return QGVector::resize(size); }
  111.     bool  insert( uint i, const type *d){ return QGVector::insert(i,(GCI)d); }
  112.     bool  remove( uint i )        { return QGVector::remove(i); }
  113.     type *take( uint i )        { return (type *)QGVector::take(i); }
  114.     void  clear()            { QGVector::clear(); }
  115.     bool  fill( const type *d, int size=-1 )
  116.                     { return QGVector::fill((GCI)d,size);}
  117.     void  sort()            { QGVector::sort(); }
  118.     int      bsearch( const type *d ) const{ return QGVector::bsearch((GCI)d); }
  119.     int      findRef( const type *d, uint i=0 ) const
  120.                     { return QGVector::findRef((GCI)d,i);}
  121.     int      find( const type *d, uint i= 0 ) const
  122.                     { return QGVector::find((GCI)d,i); }
  123.     uint  containsRef( const type *d ) const
  124.                 { return QGVector::containsRef((GCI)d); }
  125.     uint  contains( const type *d ) const
  126.                     { return QGVector::contains((GCI)d); }
  127.     type *operator[]( int i ) const    { return (type *)QGVector::at(i); }
  128.     type *at( uint i ) const        { return (type *)QGVector::at(i); }
  129.     void  toList( QGList *list ) const    { QGVector::toList(list); }
  130. private:
  131.     void  deleteItem( GCI d ) { if ( del_item ) delete (type *)d; }
  132. };
  133.  
  134. #endif // USE_TEMPLATECLASS
  135.  
  136.  
  137. #endif // QVECTOR_H
  138.